package com.example.superoa.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.example.superoa.model.service.ChaxunService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

@Controller
public class ChaxunController {
	@Autowired
	private ChaxunService cs;
	@RequestMapping("salary-chaxun")
	public void test1() {
		 
	}
	@RequestMapping("show-chaxun")
	@ResponseBody
	public Map<String,Object> test1(int page,int rows) {
		Map<String,Object> map = new HashMap<>();
			//先分页
		Page<Object> pg = PageHelper.startPage(page, rows);		
		JSONArray i=cs.cx();
		//总记录
		map.put("total", pg.getTotal());
		//页内容
		map.put("rows", i);
		return map;
	}
	@RequestMapping("find-pay-staff")
	@ResponseBody
	public JSONArray test3() {
		return cs.fs();
	}
	
	@RequestMapping("find-pay-staffname")
	@ResponseBody
	public Map<String,Object> test4(int page,int rows,int staff_id) {
		Map<String,Object> map = new HashMap<>();
			//先分页
		Page<Object> pg = PageHelper.startPage(page, rows);
		JSONArray i=cs.fn(staff_id);
		//总记录
		map.put("total", pg.getTotal());
		//页内容
		map.put("rows", i);
		return map;
	}
	@RequestMapping("salary-ck-kaoqing")
	public void jiemian(int sd_id,Model model) {
		JSONArray ids = cs.cx_kq(sd_id);
		System.err.println(ids.get(0));
		model.addAttribute("kq",ids.get(0));
	}
	
	@RequestMapping("finddetails")
	@ResponseBody
	public JSONArray finddetails(int staff_id) {
		return cs.finddetails(staff_id);
	}
	@RequestMapping("sss")
	@ResponseBody
	public JSONArray sss(int staff_id) {
		return cs.finddetails(staff_id);
	}
}
